import axios from "axios";
export default({
	data: {
		music: "",
		musicList: [],
		musicURL: "",
		picUrl: "",
		hotComments: [],
		// 动画的显示与隐藏
		isPlaying: false,
		mvId: "",
		mvUrl: "",
		// 遮罩层的显示与隐藏
		isShow: false		
	},
	methods: {
		// 歌曲搜索
		search:function(music) {
			var that = this;
			axios.get("https://autumnfish.cn/search?keywords=" + music)
			.then(function(response) {
				console.log(response);
				that.musicList = response.data.result.songs;
			}, function(err) {
				console.log(err);
			})
		},
		// 歌曲播放
		playMusic: function(musicId) {
			var that = this;
			axios.get("https://autumnfish.cn/song/url?id="+musicId)
			.then(function(response) {
				that.musicURL = response.data.data[0].url;
			}, function(err) {
				console.log(err);
			});
			// 歌曲封面
			axios.get("https:autumnfish.cn/song/detail?ids="+musicId)
			.then(function(response){
				console.log(1);
				// console.log(response);
				that.picUrl = response.data.songs[0].al.picUrl;
			},function(err){
				console.log(err);
			});
			// 歌曲评论
			axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicId)
			.then(function(response) {
				console.log(2);
				// console.log(response);
				// console.log(response.data.hotComments);
				that.hotComments = response.data.hotComments;
			}, function(err) {
				console.log(err);
			})
		},
		// 播放动画
		play: function() {
			// console.log("play");
			this.isPlaying = true;
		},
		pause: function() {
			// console.log("pause");
			this.isPlaying = false;
		},
		// 播放mv
		mvPlay: function(mvId) {
			var that = this;
			axios.get("https://autumnfish.cn/mv/url?id=" + mvId)
			.then(function(response) {
				console.log(3);
				that.isShow = true;
				that.mvUrl = response.data.data.url;
			}, function(err) {
				console.log(err);
			})
		},
		hide: function() {
			this.isShow = false;
		}
		

	}
})
